const fs = require('fs');

var total_grid_json = {
    'type': 'FeatureCollection',
    'features': []
};

function create_grid() {
    var startX = 115.25, endX = 116.35;
    var startY = 40, endY = 40.1;
    var detaX = 0.005, detaY = 0.004;
    for (var x = startX; x <= endX; x += detaX) {
        for (var y = startY; y <= endY; y += detaY) {
            total_grid_json.features.push(
                {
                    'type': 'Feature',
                    'properties': {
                        'color': "#457845"
                    },
                    'geometry': {
                        'type': 'Polygon',
                        'coordinates': [
                            [
                                [x, y],
                                [x + detaX, y],
                                [x + detaX, y + detaY],
                                [x, y + detaY],
                                [x, y],
                            ]
                        ]
                    }
                }
            )
        }
    }
}

create_grid();
var str = JSON.stringify(total_grid_json);
fs.writeFileSync('grid.js',str,'utf8');
console.log('Success');